package com.houmeiyuan.huiguniang.service;

import com.houmeiyuan.huiguniang.modles.dao.AddressDao;
import com.houmeiyuan.huiguniang.modles.domain.Address;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service
public class AddressService {
    @Autowired
    public AddressDao addressDao;

    /**
     * @author fanfan
     * 通过openId和id获取收获地址信息
     * @param mp
     * @return
     */
    public Address fetchByAddressId(Map<String,Object> mp)
    {
        return addressDao.fetchByAddressId(mp);
    }

    /**
     * @author fanfan
     * 通过openId查询用户的所有收货地址
     * @param mp
     * @return
     */
    public List fetchAll(Map<String,Object> mp)
    {
        return addressDao.fetchAll(mp);
    }

    /**
     * @author fanfan
     * 增加地址地址
     * @param address
     * @return
     */
    @Transactional
    public Integer addAddress(Address address)
    {
        return addressDao.addAddress(address);
    }

    /**
     * 删除地址
     *@author fanfan
     * @param id
     * @return
     */
    @Transactional
    public Integer deleteAddress(Integer id){
        return addressDao.deleteAddress(id);
    }


    @Transactional
    public Integer update(Address address) {
        return addressDao.update(address);
    }
}
